home *** CD-ROM | disk | FTP | other *** search
/ ...taking it to the Macs! / ...taking it to the Macs!.iso / Extras / ActiveX Mac SDK / ActiveX SDK / Sample Controls / Ticker / CTickerError.cp < prev    next >
Encoding:
Text File  |  1996-12-20  |  2.8 KB  |  133 lines  |  [TEXT/CWIE]

  1. #include "ocheaders.h"
  2. #include "CBaseControl.h"
  3. #include "CErrorControl.h"
  4. #include "CTick.h"
  5. #include "CTickerControl.h"
  6. #include "CError.h"
  7. #include "CTickerError.h"
  8. #include "FnAssert.h"
  9.  
  10. #define MControl ((CTickerControl *)mControl)
  11.  
  12. ///////////////////////////////////////////////////////////////////////////////
  13. //
  14. // CTickerError::CTickerError
  15. //
  16.  
  17. CTickerError::CTickerError(ErrorCode error) : CError(error)
  18. {
  19. }
  20.  
  21. CTickerError::CTickerError(ErrorCode error, CErrorControl * control)
  22.     : CError(error, control)
  23. {
  24. }
  25.  
  26. CTickerError::CTickerError(ErrorCode error, CTick * tick)
  27.     : CError(error)
  28. {
  29.     mTick = tick;
  30.     mControl = (mTick ? mTick->mControl : NULL);
  31. }
  32.  
  33. ///////////////////////////////////////////////////////////////////////////////
  34. //
  35. // CTickerError::Init
  36. //
  37. void CTickerError::Init(ErrorCode error, CErrorControl * control)
  38. {
  39.     inherited::Init(error, control);
  40.     
  41.     mTick = NULL;
  42. }
  43.  
  44. ///////////////////////////////////////////////////////////////////////////////
  45. //
  46. // CTickerError::HandleError
  47. //
  48.  
  49. void CTickerError::HandleError(void)
  50. {
  51.     switch ( mErrorCode )
  52.     {
  53.         case CONTROL_GWORLD_ALLOCATION_ERROR:
  54.         {
  55.             ASSERT((MControl != NULL), "Unexpected null control in error handler!");
  56.             if ( MControl->mOffscreenGWorld != NULL )
  57.             {
  58.                 DisposeGWorld( MControl->mOffscreenGWorld );
  59.                 MControl->mOffscreenGWorld = NULL;
  60.                 MControl->mPixOffscreenPixMap = NULL;
  61.             }
  62.             
  63.             break;
  64.         }
  65.  
  66.         case TICK_GWORLD_ALLOCATION_ERROR:
  67.         {
  68.             ASSERT((MControl != NULL), "Unexpected null control in error handler!");
  69.             if ( mTick->mGWorld )
  70.                 DisposeGWorld( mTick->mGWorld );
  71.             mTick->mGWorld = NULL;
  72.             mTick->mPixMap = NULL;
  73.             
  74.             break;
  75.         }
  76.         
  77.         case NAME_TOKENIZE_ALLOCATION_ERROR:
  78.         case VALUE_TOKENIZE_ALLOCATION_ERROR:
  79.             break; // handled in CTickerControl's general cleanup
  80.         
  81.         case FONTINFO_ALLOCATION_ERROR:
  82.             break;
  83.         
  84.         case TICK_NAME_ALLOCATION_ERROR:
  85.         case TICK_VALUE_ALLOCATION_ERROR:
  86.         {
  87.             // if we can't set allocate the name or the value, don't use this tick
  88.             
  89.             ASSERT((MControl != NULL), "Unexpected null control in error handler!");
  90.             if ( mTick != NULL )
  91.             {
  92.                 // Delete the Tick in the new que, if it's there.  Note that we
  93.                 // assume the NEW que (mQNew) here because that's where things
  94.                 // get put when we're parsing.
  95.                 deque<CTick*>::iterator it = MControl->mQNew.begin();
  96.                 while (it != MControl->mQNew.end())
  97.                 {
  98.                     CTick* pTick = *it;
  99.                     ASSERT((pTick != NULL), "NULL Tick!") ;
  100.                     if ( pTick == mTick )
  101.                     {
  102.                         MControl->mQNew.erase(it, it);
  103.                         break;
  104.                     }
  105.                     it++;
  106.                 }
  107.                 
  108.                 // delete the tick.
  109.                 delete mTick;
  110.                 mTick = NULL;
  111.             }
  112.             
  113.             break;
  114.         }
  115.         
  116.         case DATA_ALLOCATION_ERROR:
  117.         {
  118.             break;
  119.         }
  120.         
  121.         case DATA_REALLOCATION_ERROR:
  122.         {
  123.             MControl->mData = MControl->mDataTemp;
  124.             MControl->mDataTemp = NULL;
  125.             
  126.             break;
  127.         }
  128.             
  129.         default:
  130.             break;
  131.     }
  132. }
  133.